package com.k12.app.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.stp.StpUtil;
import com.k12.app.rpc.UserFeignClient;
import com.k12.app.utils.RocketMQProducer;
import com.k12.common.model.resp.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class AppUserController {




    @Resource
    private RocketMQProducer rocketMQProducer;

    @Resource
    private UserFeignClient userFeignClient;


    @GetMapping("/app/user/login")
    public R<String> Login()
    {
        StpUtil.login(1);
        System.out.println("token:"+StpUtil.getTokenInfo().tokenName);
        System.out.println("token:"+StpUtil.getTokenInfo().tokenValue);
        return R.success(StpUtil.getTokenInfo().tokenValue);
    }

    @SaCheckLogin
    @GetMapping("/app/user/getUserInfo")
    public R<String> getUserInfo()
    {
        userFeignClient.getUserInfo();
        return R.success(StpUtil.getTokenInfo().tokenValue);
    }

    @SaCheckPermission("user:find")
    @GetMapping("/app/user/getRPUserInfo")
    public R<String> getUserInfoByPerOrRole()
    {
        return R.success(StpUtil.getTokenInfo().tokenValue);
    }



    @GetMapping("/app/user/getNoUserInfo")
    public R<String> getNoUserInfo()
    {
        return R.success(StpUtil.getTokenInfo().tokenValue);
    }

}
